#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include "MapItem.h"

class MapScene;

QT_BEGIN_NAMESPACE
class QAction;
class QToolBox;
class QComboBox;
class QButtonGroup;
class QLineEdit;
class QGraphicsTextItem;
class QListWidgetItem;
class QListWidget;
class QToolButton;
class QAbstractButton;
class QGraphicsView;
class QXmlStreamReader;
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
   MainWindow();

private slots:
    void buttonGroupClicked(int id);
	void listItemClicked(QListWidgetItem*);
    void deleteItem();
    void pointerGroupClicked(int id);
	void startInserted(int id);
    void itemInserted(MapItem *item);
    void sceneScaleChanged(const QString &scale);
    void about();
	void fileGroupClicked(int id);
	void openFile();
	void createNewFile();
	void saveFile();
	void toolboxSelectionChanged(int boxId);

private:
    void createToolBox();
	void createToolbars();
    void createActions();
    void createMenus();
	void handleMapInfo(QXmlStreamReader& xml);
	void handleCells(QXmlStreamReader& xml);

    QWidget *createBackgroundCellWidget(const QString &text,
                                        const QString &image);
    QWidget *createCellWidget(const QString &text,
                              MapItem::DiagramType type);
    QMenu *createColorMenu(const char *slot, QColor defaultColor);
    QIcon createColorToolButtonIcon(const QString &image, QColor color);
    QIcon createColorIcon(QColor color);

	QListWidget *pathsListView;

    MapScene *scene;
    QGraphicsView *view;

	QAction *newFileAction;
	QAction *openFileAction;
	QAction *saveFileAction;

    QAction *exitAction;
    QAction *addAction;
    QAction *deleteAction;
    QAction *aboutAction;

    QMenu *fileMenu;
    QMenu *itemMenu;
    QMenu *viewMenu;
    QMenu *aboutMenu;

	QToolBar *filesToolBar;

    QToolBar *textToolBar;
    QToolBar *editToolBar;
    QToolBar *pointerToolbar;

    QComboBox *sceneScaleCombo;

    QToolBox *toolBox;
    QButtonGroup *buttonGroup;
	QButtonGroup *fileButtonGroup;
    QButtonGroup *pointerTypeGroup;
    QButtonGroup *backgroundButtonGroup;
};

#endif
